package com.lx.encryption.plugin;

import com.lx.encryption.plugin.util.AgentTransformer;
import com.lx.encryption.plugin.util.ArgumentParser;
import com.lx.encryption.plugin.util.Log;

import java.lang.instrument.Instrumentation;

/**
 * @author liuzhiqiang
 */
public class BeforeLoadAgent {

    public static void premain(String agentArgs, Instrumentation inst) {
        Log.info(agentArgs);
        String pwd = ArgumentParser.analysis(agentArgs, "pwd");
        Log.info("从命令行获取密码[" + pwd + "]");
        if (inst != null) {
            AgentTransformer tran = new AgentTransformer(pwd);
            inst.addTransformer(tran);
        }
    }
}
